package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmChannelDto;
import com.heima.wemedia.service.WmChannelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/channel")
public class WmChannelController {
    @Autowired
    private WmChannelService wmChannelService;

    /**
     * 获取所有频道数据
     * @return
     */
    @GetMapping("/channels")
    public ResponseResult findAll(){
        return wmChannelService.findAll();
    }

    /**
     * 频道名称模糊分页查询
     */
    @PostMapping("/list")
    public ResponseResult list(@RequestBody WmChannelDto dto){
        return wmChannelService.list(dto);
    }

    /**
     * 新增频道
     * @param dto
     * @return
     */
    @PostMapping("/save")
    public ResponseResult save(@RequestBody WmChannelDto dto){
        return wmChannelService.save(dto);
    }

    /**
     * 修改频道
     * @param dto
     * @return
     */
    @PostMapping("/update")
    public ResponseResult update(@RequestBody WmChannelDto dto){
        return wmChannelService.update(dto);
    }

    /**
     * 删除频道
     * @param id
     * @return
     */
    @GetMapping("/del/{id}")
    public ResponseResult delete(@PathVariable Integer id){
        return wmChannelService.delete(id);
    }
}